summaryrefslogtreecommitdiffstats
path: root/src/yuzu/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/yuzu/main.cpp')
-rw-r--r--src/yuzu/main.cpp54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp
index defe45198..cf61d4258 100644
--- a/src/yuzu/main.cpp
+++ b/src/yuzu/main.cpp
@@ -185,6 +185,10 @@ __declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
}
#endif
+#ifdef __linux__
+#include <gamemode_client.h>
+#endif
+
constexpr int default_mouse_hide_timeout = 2500;
constexpr int default_mouse_center_timeout = 10;
constexpr int default_input_update_timeout = 1;
@@ -2126,6 +2130,16 @@ void GMainWindow::OnEmulationStopped() {
discord_rpc->Update();
+#ifdef __linux__
+ if (UISettings::values.enable_gamemode) {
+ if (gamemode_request_end() < 0) {
+ LOG_WARNING(Frontend, "Failed to stop gamemode: {}", gamemode_error_string());
+ } else {
+ LOG_INFO(Frontend, "Stopped gamemode");
+ }
+ }
+#endif
+
// The emulation is stopped, so closing the window or not does not matter anymore
disconnect(render_window, &GRenderWindow::Closed, this, &GMainWindow::OnStopGame);
@@ -3504,6 +3518,16 @@ void GMainWindow::OnStartGame() {
play_time_manager->Start();
discord_rpc->Update();
+
+#ifdef __linux__
+ if (UISettings::values.enable_gamemode) {
+ if (gamemode_request_start() < 0) {
+ LOG_WARNING(Frontend, "Failed to start gamemode: {}", gamemode_error_string());
+ } else {
+ LOG_INFO(Frontend, "Started gamemode");
+ }
+ }
+#endif
}
void GMainWindow::OnRestartGame() {
@@ -3524,6 +3548,16 @@ void GMainWindow::OnPauseGame() {
play_time_manager->Stop();
UpdateMenuState();
AllowOSSleep();
+
+#ifdef __linux__
+ if (UISettings::values.enable_gamemode) {
+ if (gamemode_request_end() < 0) {
+ LOG_WARNING(Frontend, "Failed to stop gamemode: {}", gamemode_error_string());
+ } else {
+ LOG_INFO(Frontend, "Stopped gamemode");
+ }
+ }
+#endif
}
void GMainWindow::OnPauseContinueGame() {
@@ -5181,6 +5215,26 @@ void GMainWindow::SetDiscordEnabled([[maybe_unused]] bool state) {
discord_rpc->Update();
}
+void GMainWindow::SetGamemodeDisabled([[maybe_unused]] bool state) {
+#ifdef __linux__
+ if (emulation_running) {
+ if (state) {
+ if (gamemode_request_end() < 0) {
+ LOG_WARNING(Frontend, "Failed to stop gamemode: {}", gamemode_error_string());
+ } else {
+ LOG_INFO(Frontend, "Stopped gamemode");
+ }
+ } else {
+ if (gamemode_request_start() < 0) {
+ LOG_WARNING(Frontend, "Failed to start gamemode: {}", gamemode_error_string());
+ } else {
+ LOG_INFO(Frontend, "Started gamemode");
+ }
+ }
+ }
+#endif
+}
+
void GMainWindow::changeEvent(QEvent* event) {
#ifdef __unix__
// PaletteChange event appears to only reach so far into the GUI, explicitly asking to